package com.qf.controller;

import com.qf.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName AjaxController
 * @Description TODO
 * @Author 86181
 * @Date 2022/9/5 21:02
 * @Version 1.0
 **/
@Controller
@RequestMapping("ajax")
public class AjaxController {
//    @RequestMapping(value = "demo",method = RequestMethod.POST)
//    public String demo(String username,int age){
//        System.out.println(username);
//        System.out.println(age);
//        return "aa";
//    }
    @GetMapping("demo")
    @ResponseBody
    public String demo01(String username,int age){
        System.out.println(username);
        System.out.println(age);

        return "aa";
    }
    @PostMapping("demo")
    @ResponseBody
    public String demo(User user){
        System.out.println(user);
        return "aa";
    }

    @PostMapping("json")
    @ResponseBody   //响应的是json数据格式
    public User demo02(@RequestBody User user){   //@RequestBody  :contentType:applicaton/json;charset=UTF-8
        System.out.println(user);
        return user;
    }

}
